
#include "iostream"
#include "vector"
#include "unordered_map"
#include "unordered_set"
#include "algorithm"
#include "string"
#include "list"
#include "string.h"

class OneLoop{
public:
    OneLoop(int a){
        a=a+1;
        while(1){
            if(is_xunhuanshu(a)){
                printf("%d\n",a);
                return;
            }
            a++;
        }
    }
};
class Solution {
public:
    void run() {

        bool first = true;
        int a;
//        std::string s;
        while (std::cin>>a) {
            OneLoop loop(a);
        }
    }
};

int main() {
//    bool cur_num= true;
    Solution().run();
    return 0;
}

